. ../gcc-svn-env

test "x${BUILD}" != "x" || BUILD=$REG_DEFAULT_BUILD
export REG_BLD=$BUILD
HOST=$BUILD

test "x${REG_TARGET}" != "x" || REG_TARGET=$HOST
test "x${REG_CONFOPTS}" != "x" || REG_CONFOPTS=""
test "${BUILD}" = "${TARGET}" -a -n "${BINUTILS}" \
  || export PATH=${BINUTILS}:${PATH}

VERBOSITY=1
DATE_IN_MSG=1

export BUGID
export REG_CHANGESET_LIST=`pwd`/${BUGID}.list

########################################################################
# LOW_PATCH and HIGH_PATCH are for reg_search_id.
########################################################################

LOW_PATCH=1
HIGH_PATCH=`wc -l $REG_CHANGESET_LIST | awk '{ print $1 }'`

########################################################################
# REG_NEWMID, REG_FAILLIST, REG_CHECKFAIL, and REG_REPORTFAIL are
# used by reg-hunt and auxiliary scripts to continue a hunt after a
# build failure.  If REG_NEWMID is not defined then they are all
# ignored.
########################################################################

#export REG_NEWMID=${REG_BIN}/reg-newmid
#export REG_FAILLIST=`pwd`/gcc-fails-${BUILD_KIND}
export REG_CHECKFAIL=${REG_BIN}/gcc-svn-checkfail
export REG_RECORDFAIL=${REG_BIN}/gcc-svn-recordfail

########################################################################
# REG_UPDATE, REG_BUILD, and REG_TEST are used by several scripts.
# You can use these or provide your own.
########################################################################

export REG_UPDATE=${REG_BIN}/gcc-svn-update

export REG_BUILD=${REG_BIN}/gcc-build-${BUILD_KIND}
  # Variables defined below are specific to gcc-build-${BUILD_KIND}
  REG_CONFOPTS="$REG_CONFOPTS --build=${BUILD}"
  REG_CONFOPTS="$REG_CONFOPTS --host=${HOST}"
  REG_CONFOPTS="$REG_CONFOPTS --target=${REG_TARGET}"
  if [ -n "$GMP" ]; then
    REG_CONFOPTS="$REG_CONFOPTS --with-gmp=$GMP"
    REG_CONFOPTS="$REG_CONFOPTS --with-mpfr=$GMP"
  fi
  REG_CONFOPTS="$REG_CONFOPTS --disable-libmudflap"
  REG_CONFOPTS="$REG_CONFOPTS --disable-libssa"

  if [ "${BUILD_KIND}" != "simple" -a -n "${BINUTILS}" ]; then
    REG_CONFOPTS="$REG_CONFOPTS --with-as=${BINUTILS}/as"
    REG_CONFOPTS="$REG_CONFOPTS --with-ld=${BINUTILS}/ld"
  fi

  case $LANG in
    c)
      REG_LANGS="c"
      SUFFIX=c
      case $BUILD_KIND in
        simple)    REG_COMPILER=cc1;;
        full)      REG_COMPILER=gcc;;  
        bootstrap) REG_COMPILER=gcc;;  
        *)         msg 0 "unrecognized BUILD_KIND: $BUILD_KIND"; exit 1;
      esac
      ;;
    c++)
      REG_LANGS="c,c++"
      SUFFIX=cc
      case $BUILD_KIND in
        simple)    REG_COMPILER=cc1plus;;
        full)      REG_COMPILER=g++;;  
        bootstrap) REG_COMPILER=g++;;  
        *)         msg 0 "unrecognized BUILD_KIND: $BUILD_KIND"; exit 1;
      esac
      ;;
    f77)
      REG_LANGS="c,f77"
      SUFFIX=f
      case $BUILD_KIND in
        simple)    REG_COMPILER=f771;;
        full)      REG_COMPILER=g77;;  
        bootstrap) REG_COMPILER=g77;;  
        *)         msg 0 "unrecognized BUILD_KIND: $BUILD_KIND"; exit 1;
      esac
      ;;
    f95)
      REG_LANGS="c,f95"
      SUFFIX=f90
      case $BUILD_KIND in
        simple)    REG_COMPILER=f951;;
        full)      REG_COMPILER=gfortran;;  
        bootstrap) REG_COMPILER=gfortran;;  
        *)         msg 0 "unrecognized BUILD_KIND: $BUILD_KIND"; exit 1;
      esac
      ;;
    *) msg 0 "unrecognized LANG: $LANG"; exit 1;;
  esac
  export REG_TARGET
  export REG_CONFOPTS
  export REG_GCCSRC=${REG_SRCDIR}/gcc
  export REG_LANGS
  export REG_COMPILER

export REG_TEST=${REG_BIN}/gcc-test-${BUG_KIND}
  # Variables defined below are specific to gcc-${BUG_KIND}
  case $BUILD_KIND in
    simple) REG_TEST_COMPILER="${REG_OBJDIR}/gcc/${REG_COMPILER} -quiet";;
    *)      REG_TEST_COMPILER="${REG_PREFIX}/bin/${REG_COMPILER}";
            case $BUG_KIND in
	      wrong-code) ;;
	      *)          REG_TEST_COMPILER="$REG_TEST_COMPILER -c";;
            esac;
            ;;
  esac
  export REG_TEST_COMPILER
  export REG_OPTS="${OPTS}"
  export REG_TESTCASE=${BUGID}.${SUFFIX}

  # Return values of the test scripts depend on whether we're looking
  # for the patch that introduced a bug or the one that fixed it.
  case $FIND in
    break) REG_PASS=1; REG_FAIL=0;;
    fix)   REG_PASS=0; REG_FAIL=1;;
    *)     msg 0 "error: unrecognized FIND: $FIND"; exit 1;;
  esac
  REG_ERROR=2
  export REG_PASS REG_FAIL REG_ERROR
